cd "/Users/anahi1/Desktop/anahi/WK Google Neo/Datos/stata analysis"


 import excel "/Users/anahi1/Desktop/anahi/WK Google Neo/Datos/Neonatos_inicial_ultimos_12m-20250213.xls", sheet("Neonatos_inicial_ultimos_12m-20") firstrow clear


 save neonatosinicialMar2025.dta

 import excel "/Users/anahi1/Desktop/anahi/WK Google Neo/Datos/Referencias_neonatales_ult_12m.xls", sheet("Slo recien nacidos") firstrow clear


 save referenciasneonatales1.dta


 merge 1:1 OpenID using neonatosinicial1 , generate(_mergeneonatosinicial1)

 
 save merged_neonatos1
 

generate genero = 1 if CHILDGENDER  == "Femenino"
 replace genero = 2 if CHILDGENDER  == "Masculino"

 
 generate tipo_referencia = 1 if Tipodereferencia == "emergencia"
replace tipo_referencia = 2 if Tipodereferencia == "rutinaria"
 replace tipo_referencia = 3 if Tipodereferencia == "Visita de Seguimiento"



generate tipo_parto = 1 if Tipodeparto == "Parto vaginal"
replace tipo_parto = 2 if Tipodeparto == "Delivery by cesarean section"


generate birth_attendant = 1 if Birthprovider == "comadrona"
replace birth_attendant = 2 if Birthprovider == "enfermera"
replace birth_attendant = 3 if Birthprovider == "medico"
replace birth_attendant = 4 if Birthprovider == "otro"

generate lbw_vlbw = 0 if BirthWeightlbs >= 5.5 
replace lbw_vlbw = 1 if BirthWeightlbs >= 3.3 & BirthWeightlbs < 5.5
replace lbw_vlbw = 2 if BirthWeightlbs < 3.3 

generate lbw = 0 if BirthWeightlbs >= 5.5 
replace lbw = 1 if BirthWeightlbs <= 5.49

generate bajopeso = . 
replace bajopeso = 0 if BirthWeightlbs >= 5.5 & BirthWeightlbs != .
replace bajopeso = 1 if BirthWeightlbs <= 5.49 & BirthWeightlbs != .


generate birth_location = 1 if LOCATIONOFBIRTH == "Hospital"
replace birth_location = 2 if LOCATIONOFBIRTH == "Hogar"
replace birth_location = 3 if birth_location == .

generate ageatvisit = 1 if edadprimeravisita >= 0 & edadprimeravisita <=3
replace ageatvisit = 2 if edadprimeravisita >= 4 & edadprimeravisita <=7
replace ageatvisit = 3 if edadprimeravisita >= 8 & edadprimeravisita <=14
replace ageatvisit = 4 if edadprimeravisita >= 15 & edadprimeravisita <=30
replace ageatvisit = 5 if edadprimeravisita >= 31 

generate feedingmethod = 1 if Feedingplan == "BREASTFED EXCLUSIVELY"
replace feedingmethod = 2 if Feedingplan == "MIXED FEEDING"
replace feedingmethod = 3 if feedingmethod == .

generate firstbreastfeed = 1 if Horadeprimeraalimentacion == "Menos de una hora"
replace firstbreastfeed = 2 if Horadeprimeraalimentacion == "1-4 horas"
replace firstbreastfeed = 3 if Horadeprimeraalimentacion == "Despues de 4 horas"

generate prematurity = .
replace prematurity = 0 if gestationalageatbirthmonths >= 37 & gestationalageatbirthmonths != .
replace prematurity = 1 if gestationalageatbirthmonths < 37 & gestationalageatbirthmonths != .



